﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
//using LTP.Accounts.Bus;
namespace xxxy.Web.personalInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int pID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(pID);
				}
			}
		}
			
	private void ShowInfo(int pID)
	{
		xxxy.BLL.personalInfo bll=new xxxy.BLL.personalInfo();
		xxxy.Model.personalInfo model=bll.GetModel(pID);
		this.lblpID.Text=model.pID.ToString();
		this.txtpDataName.Text=model.pDataName;
		this.txtpIssuingTime.Text=model.pIssuingTime.ToString();
		this.txtpUploadTime.Text=model.pUploadTime.ToString();
		this.txtpDepartment.Text=model.pDepartment;
		this.txtpAddress.Text=model.pAddress;
		this.txtpAttachments1.Text=model.pAttachments1;
		this.txtpAttachments2.Text=model.pAttachments2;
		this.txtpRemarks.Text=model.pRemarks;
		this.txtpStation.Text=model.pStation.ToString();
		this.txtpUploadName.Text=model.pUploadName.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtpDataName.Text.Trim().Length==0)
			{
				strErr+="资料名称不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtpIssuingTime.Text))
			{
				strErr+="发证时间格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtpUploadTime.Text))
			{
				strErr+="上传时间格式错误！\\n";	
			}
			if(this.txtpDepartment.Text.Trim().Length==0)
			{
				strErr+="发证机构不能为空！\\n";	
			}
			if(this.txtpAddress.Text.Trim().Length==0)
			{
				strErr+="存放地址不能为空！\\n";	
			}
			if(this.txtpAttachments1.Text.Trim().Length==0)
			{
				strErr+="照片1不能为空！\\n";	
			}
			if(this.txtpAttachments2.Text.Trim().Length==0)
			{
				strErr+="照片2不能为空！\\n";	
			}
			if(this.txtpRemarks.Text.Trim().Length==0)
			{
				strErr+="备注不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtpStation.Text))
			{
				strErr+="审核状态格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtpUploadName.Text))
			{
				strErr+="上传人格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int pID=int.Parse(this.lblpID.Text);
			string pDataName=this.txtpDataName.Text;
			DateTime pIssuingTime=DateTime.Parse(this.txtpIssuingTime.Text);
			DateTime pUploadTime=DateTime.Parse(this.txtpUploadTime.Text);
			string pDepartment=this.txtpDepartment.Text;
			string pAddress=this.txtpAddress.Text;
			string pAttachments1=this.txtpAttachments1.Text;
			string pAttachments2=this.txtpAttachments2.Text;
			string pRemarks=this.txtpRemarks.Text;
			int pStation=int.Parse(this.txtpStation.Text);
			int pUploadName=int.Parse(this.txtpUploadName.Text);


			xxxy.Model.personalInfo model=new xxxy.Model.personalInfo();
			model.pID=pID;
			model.pDataName=pDataName;
			model.pIssuingTime=pIssuingTime;
			model.pUploadTime=pUploadTime;
			model.pDepartment=pDepartment;
			model.pAddress=pAddress;
			model.pAttachments1=pAttachments1;
			model.pAttachments2=pAttachments2;
			model.pRemarks=pRemarks;
			model.pStation=pStation;
			model.pUploadName=pUploadName;

			xxxy.BLL.personalInfo bll=new xxxy.BLL.personalInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
